package com.itboye.lottery.activity.user

import android.content.Intent
import android.support.v4.app.Fragment
import android.view.View
import com.itboye.bylibrary.listener.MyClickListener
import com.itboye.lottery.R
import com.itboye.lottery.adapter.CommonPagerAdapter
import com.itboye.lottery.base.BaseActivity
import com.itboye.lottery.fragment.home.football.TouZhuFragment
import kotlinx.android.synthetic.main.activity_tou_zhu_record.*
import java.util.*

class TouZhuRecordActivity : BaseActivity() {
    var type = 0
    override fun getLayoutId(): Int {
        return R.layout.activity_tou_zhu_record
    }


    private var orderFragments: MutableList<Fragment>? = null
    override fun initData() {
        initFragment()
    }

    private fun initFragment() {
        var titleArray = 0
        orderFragments = ArrayList<Fragment>()
        type = intent.getIntExtra("type", 0)
        when (type) {
            0 -> {//投注记录
                setTitle("投注记录")
                titleArray = R.array.touzhu_record_title
                //0.全部 1.中奖 2.未中奖 3.未完成
                orderFragments!!.add(TouZhuFragment.newInstance(0, type))
                orderFragments!!.add(TouZhuFragment.newInstance(1, type))
                orderFragments!!.add(TouZhuFragment.newInstance(2, type))
//                orderFragments!!.add(TouZhuFragment.newInstance(3, type))
            }
            1 -> {//我的跟单
                setTitle("我的跟单")
                rightTextValue("我的推荐", MyClickListener {
                    startActivity(Intent(this, TouZhuRecordActivity::class.java)
                            .putExtra("type", 2))
                })
                titleArray = R.array.gendan_record_title
                //1.全部 2.待开奖 3.已中奖 4.未中奖
                orderFragments!!.add(TouZhuFragment.newInstance(1, type))
                orderFragments!!.add(TouZhuFragment.newInstance(2, type))
                orderFragments!!.add(TouZhuFragment.newInstance(3, type))
                orderFragments!!.add(TouZhuFragment.newInstance(4, type))
            }
            2 -> {//我的推荐
                setTitle("我的推荐")
                rightTextValue("我的跟单", MyClickListener {
                    startActivity(Intent(this, TouZhuRecordActivity::class.java)
                            .putExtra("type", 1))
                })
                titleArray = R.array.gendan_record_title
                //1.全部 2.待开奖 3.已中奖 4.未中奖
                orderFragments!!.add(TouZhuFragment.newInstance(1, type))
                orderFragments!!.add(TouZhuFragment.newInstance(2, type))
                orderFragments!!.add(TouZhuFragment.newInstance(3, type))
                orderFragments!!.add(TouZhuFragment.newInstance(4, type))
            }
            else -> {
            }
        }
        vp_touzhu_record.adapter = CommonPagerAdapter(this, orderFragments, titleArray, supportFragmentManager)
        vp_touzhu_record.offscreenPageLimit = 5
        tl_touzhu_record.setupWithViewPager(vp_touzhu_record)
        vp_touzhu_record.setCurrentItem(intent.getIntExtra("order_position", 0), false)
    }

    override fun onClick(p0: View?) {
    }
}
